import app from './app';
import path from 'path';

async function main() {
  const port = process.env['PORT'] || 8080;
  const host = process.env['HOST'] || '';

  await new Promise((res, rej) => {
    const server = app.listen(port, host, res);
    server.on('error', rej);
  });
  console.log('Ready');
}

main()
  .catch(err => {
    console.log(err.errors);
    setImmediate(() => {
      throw err;
    });
  });
